const install = (Vue, vm) => {
	vm.$u.api={}
	// 首页
	vm.$u.api.getIndex = (params = {}) => vm.$u.get('/api/index', params);//获取首页数据
	
	// 商品
	vm.$u.api.getGoodsList = (params = {}) => vm.$u.get(`/api/goods`,params);//商品列表
	vm.$u.api.getGoodsDetail = id => vm.$u.get(`/api/goods/${id}`);//商品详情
	vm.$u.api.getCollect = (page=1) => vm.$u.get('/api/collects',{page}) //获取收藏商品
	vm.$u.api.isCollect = id => vm.$u.post(`/api/collects/goods/${id}`);//商品收藏或取消
	
	// 购物车相关
	vm.$u.api.addCart = params => vm.$u.post(`/api/carts`,params);//添加购物车
	vm.$u.api.cartGoods = () => vm.$u.get(`/api/carts?include=goods`);//购物车列表
	vm.$u.api.numChange = (cart,num) => vm.$u.put(`/api/carts/${cart}`,{num});//购物车商品数量改变
	vm.$u.api.delCartGoods = cart => vm.$u.delete(`/api/carts/${cart}`);//将商品移出购物车
	vm.$u.api.isCheck = cart_ids => vm.$u.patch(`/api/carts/checked`,{cart_ids});//将商品选中与否
	
	// 个人中心
	vm.$u.api.getUserInfo = () => vm.$u.get('/api/user') //获取用户信息
	vm.$u.api.setUserInfo = params => vm.$u.put('/api/user',params) //更新用户信息
	
	// 认证相关的
	vm.$u.api.authLogin = params => vm.$u.post('/api/auth/login', params)//登录
	vm.$u.api.authLoginOut = () => vm.$u.post('/api/auth/logout')//退出登录
	vm.$u.api.authRegister = params => vm.$u.post('/api/auth/register', params)//注册
	vm.$u.api.authOss = () => vm.$u.get('/api/auth/oss/token')//获取oss
	vm.$u.api.authAvatar = params => vm.$u.patch('/api/user/avatar',params)//用户更改头像
	// 订单相关的
	vm.$u.api.ordersPreview = () => vm.$u.get('/api/orders/preview')//订单预览
	vm.$u.api.ordersSubmit = (params) => vm.$u.post('/api/orders',params)//提交订单
	vm.$u.api.ordersDetail = (orderId) => vm.$u.get(`/api/orders/${orderId}?include=orderDetails.goods,address`)//订单详情
	vm.$u.api.ordersList = (page,title,status) => vm.$u.get(`/api/orders?include=orderDetails.goods&page=${page}&title=${title}&status=${status}`)//订单列表
	vm.$u.api.ordersPost = (orderId,params) => vm.$u.patch(`/api/admin/orders/${orderId}/post`,params)//发货
	vm.$u.api.ordersConfirm = (orderId) => vm.$u.patch(`/api/orders/${orderId}/confirm`)//订单签收
	
	//支付相关
	vm.$u.api.payErweiMa = (orderId,type) => vm.$u.get(`/api/orders/${orderId}/pay?type=aliyun`)//获取支付二维码
	vm.$u.api.payStatus = (orderId) => vm.$u.get(`/api/orders/${orderId}/status`)//订单签收
	
	
	//物流相关
	vm.$u.api.expressDetail = (orderId) => vm.$u.get(`/api/orders/${orderId}/express`)//物流详情
	vm.$u.api.confirm = (orderId) => vm.$u.patch(`/api/orders/${orderId}/confirm`)//确认收货
	vm.$u.api.express = (orderId) => vm.$u.get(`/api/orders/${orderId}/comment`)//评价商品
	
	//评论相关
	vm.$u.api.commentAdd = (orderId,params) => vm.$u.post(`/api/orders/${orderId}/comment`,params)//添加评论

	
	//地址管理
	vm.$u.api.addressList = () => vm.$u.get('/api/address')//地址列表
	vm.$u.api.addressAdd = (params) => vm.$u.post('/api/address',params)//添加地址
	vm.$u.api.addressDefault = (params) => vm.$u.post(`/api/address/${addressId}/default`,params)//设置为默认地址
	vm.$u.api.addressDetail = (addressId) => vm.$u.get(`/api/address/${addressId}`)//地址详情
	vm.$u.api.addressEdit = (addressId,params) => vm.$u.put(`/api/address/${addressId}`,params)//更新地址
	vm.$u.api.addressDelete = (addressId) => vm.$u.delete(`/api/address/${addressId}`)//删除地址
	
	
	// 后端
	vm.$u.api.addGoods1 = (id,params) => vm.$u.put(`/api/admin/goods/${id}`,params)//xiugai商品
	vm.$u.api.addGoods2 = () => vm.$u.get(`/api/admin/goods`)//商品列表
	vm.$u.api.addGoods3 = id => vm.$u.patch(`/api/admin/goods`,id)//上架列表
	
	vm.$u.api.getBanner = () => vm.$u.get(`/api/admin/slides`)//获取轮播
	vm.$u.api.setBanner = (slide,params) => vm.$u.put(`/api/admin/slides/${slide}`,params)//修改轮播
	vm.$u.api.sortBanner = (slide,seq) => vm.$u.patch(`/api/admin/slides/${slide}/seq`,{seq})//修改轮播
	
	//地图相关
	vm.$u.api.getLocation = (longitude,latitude,key) => vm.$u.post(`https://restapi.amap.com/v3/geocode/regeo?output=json&location=${longitude},${latitude}&key=${key}&radius=1000&extensions=all`)//位置
}

export default {
	install
}
